home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3711 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  865 b 

  1. Path: airdmhor.gen.nz!not-for-mail
  2. From: gumboot@airdmhor.gen.nz (Simon Hosie)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: division problem
  5. Date: 31 Jan 1996 06:52:58 +1300
  6. Organization: Airdmhor
  7. Message-ID: <4elltq$c6u@airdmhor.gen.nz>
  8. References: <31097D77.11AA@rain.org> <26JAN199622082450@erich.triumf.ca> <4eh246$u6h@airdmhor.gen.nz> <4ej4ha$66@fountain.mindlink.net>
  9. NNTP-Posting-Host: localhost.gen.nz
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  13. > That's disgusting!
  14. > celcius = (fahrenheit - 32) * 5 / 9;
  15. Gene Wirchenko:
  16. > That's disgusting <g> as it doesn't round.  Try it with 39 deg F:
  17. >           (39-32)*5/9 ::= 7*5/9 ::= 35/9 ::= 3
  18. > but the actual value is 3.8... i.e. nearly 4.  If you must int, 4
  19. > would be a better answer.
  20.  
  21.   celcius = ((fahrenheit - 32) * 10 + 9) / 18;
  22.  
  23.   But floating point doesn't round either.
  24.